<template>
	<view>
		<view class="search">
			<view class="cu-bar bg-white search">
				<view class="search-form round">
					<text class="cuIcon-search"></text>
					<input type="text" placeholder="请先输入机台号查询机台" confirm-type="search"
						v-model="queryParams.devNum"></input>
				</view>
				<view class="action">
					<button class="cu-btn bg-mauve shadow-blur round" @click="search">搜索</button>
				</view>
			</view>
		</view>
		<view class="cu-list menu sm-border padding">
			<u-empty v-if="dataList.length===0" icon="https://fziot.zheyun.top:9021/static/image/empty/data.png"></u-empty>
			<view class="cu-item arrow" 
			 @longpress="longpress(item)"
			 @click="updateCloth(item)"
			 v-for="item in dataList" >
				<view class="content">
					<text class="text-grey">{{item.clName}}</text>
				</view>
				<view class="action">
					<text class="text-grey text-sm">{{item.clType}}</text>
				</view>
			</view>
		</view>
		<view class='placeholder-view'></view>

	</view>
</template>

<script>
	import {
		getBindDevByNum
	} from "@/api/company/device.js";
	export default {
		data() {
			return {
				timeout:null,
				dataList: [],
				queryParams: {
					devNum: null,
					companyId: this.$store.getters.companyId,
				},
				rules: {
					
				},
			};
		},
		onReady() {

		},
		mounted() {
			
		},
		onUnload() {
			if(this.timeout){
				clearTimeout(this.timeout)
			}
			// uni.switchTab({
			//   url:"/pages/work/emp/index"
			//  })
			
		},
		methods: {
			
			close() {
				this.formData = {
						clName: null,
						clType: null,
						clPrice: null,
						companyId: this.$store.getters.companyId
					},
					this.$refs.inputDialog.close()
			},
			getDataList() {
				getBindDevByNum(this.queryParams).then(res => {
					if(res.code === 200 && res.data !== null){
						this.$modal.msgSuccess("查询成功")
						this.timeout = setTimeout(()=>{
							this.$tab.navigateTo(`/pagesA/work/emp/perBind?dev=`+decodeURIComponent(JSON.stringify(res.data)))
							},500)
					}else{
						this.$modal.msg("查无机台,请核对机台号后重新查询")
					}
				})
			},
			search() {
				this.getDataList()
			},
			
		},
	};
</script>

<style lang="scss" scoped>
	.search-area {
		display: flex;
		align-items: center;
	}

	.juzhong {
		flex-flow: row;
		justify-content: center;
		display: flex;
		align-items: center;
	}

	.placeholder-view {
		width: 100%;
		height: 150rpx;
	}
</style>
